<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>基本属性的获取</title>
    <style>
      .box {
        width: 80px;
        height: 30px;
        border: 1px solid black;
      }
      .red {
        color: red;
      }
      .greend {
        color: cadetblue;
      }
    </style>
  </head>
  <body>
    <div class="box">我不牛</div>
    <div id="box">小马哥很牛</div>
    <p>我爱你</p>
    <img src="./images/宫泽千春.png" alt="" /> <br />
    <a href="http://www.baidu.com">点击去往百度</a> <br />
    <span class="red">我的颜色是红色</span>

    <script>
      window.onload = function () {
        const box = document.querySelector(".box");
        const a = document.querySelector("a");
        const img = document.querySelector("img");
        const span = document.querySelector("span");
        // 设置id变成 box
        box.id = "box";
        // 设置a链接变成 javascript:;
        a.href = "javascript:;";
        // 设置img路径
        img.src = "./images/篠宫友里.png";
        // 更改span的类名
        // span.className = "greend";
        // span.classList.add("greend");
        // span.classList.remove("greend");
        // 更改box的文本
        box.innerText = "我牛不牛";
      };
    </script>
  </body>
</html>
